public class LeetCode852 {
    public static void main(String[] args) {
        int[] arr = {0, 1, 0};

        LeetCode852 leetCode = new LeetCode852();
        System.out.println(leetCode.peakIndexInMountainArray(arr));
    }

    public int peakIndexInMountainArray(int[] arr) {
        int length = arr.length;
        int left = 1, right = length - 2, res = 0;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (arr[mid] > arr[mid + 1]) {
                res = mid;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        return res;
    }
}
